<head>
	<title>
	</title>
</head>
<body><?php echo $aro['Aro']['model'] ?>
<h1>
Aro View: 
	<?php
	 if(strcmp($aro['Aro']['model'], 'Position' ) == 0){
		foreach($positions as $position){
			if(strcmp($aro['Aro']['foreign_key'], $position['Position']['id']) == 0)
			{
				echo $position['Position']['position'];
				break;
			}
		}
	} 
	else{
		foreach($members as $member){
			if(strcmp($aro['Aro']['foreign_key'], $member['UnionMember']['id']) == 0)
			{					
				echo $member['UnionMember']['name'];
				break;
			}
		}
	} 
	?>
</h1><br /> 
	<table class="style1" id="index">
		<tr>
			<th>Aco Id</th>
			<th>Aco Alias</th>
			<th>Actions</th>
			<th>Allowed</th>
		</tr>
		<?php
		$i = 0;
		foreach($acos1 as $aco1){
			//if(strcmp($aco1['ArosAcos']['aro_id'], $aro['Aro']['id']) == 0 || $aco1['ArosAcos']['aro_id'] == null)
			
			
		?>
			<tr>
				<td><?php echo $aco1['Aco']['id']?> <?php// echo $aco1['ArosAcos']['aro_id']?></td>
				<td><?php echo $path[$i]; ?></td>
				<td>
				<?php
					 if(strcmp($aro['Aro']['model'], 'Position' ) == 0){
						 foreach($positions as $position){
							if(strcmp($aro['Aro']['foreign_key'], $position['Position']['id']) == 0)
							{
								//echo $i;
								echo $html->link('Allow', array('controller' => 'Positions', 
																'action' => 'allow',
																 $position['Position']['id'],
																 $path[$i]));
								
								echo " | ";								
								echo $html->link('Deny', array('controller' => 'Positions', 
																'action' => 'deny',
																 $position['Position']['id'],
																 $path[$i]));
								break;
							}
						}
					}  
					else{
						foreach($members as $member){
							if(strcmp($aro['Aro']['foreign_key'], $member['UnionMember']['id']) == 0)
							{					
								echo $html->link('Allow', array('controller' => 'UnionMembers', 
																'action' => 'allow',
																 $member['UnionMember']['id']),
																 $path[$i]);
								echo " | ";
								echo $html->link('Deny', array('controller' => 'UnionMembers', 
																'action' => 'deny',
																 $member['UnionMember']['id']),
																 $path[$i]);
								break;
							}
						}
					}
					 
				?> 
				</td>
				<td>
				<?php
					$aroAlias = '';
					if($aro['Aro']['model']=='Position'){
						$aroAlias = $aro['Aro']['id'];
					}
					else{
						$aroAlias = $aro['Aro']['parent_id']; 
					}
					//$aroModel = substr($aro['Aro']['model'], 0, strlen($aro['Aro']['model']));
					
					//if($this->requestAction('Aros/getAccessPermission/' . $path[$i] . '/' . $aroAlias) == true)
					if($this->requestAction('Aros/getPerm/' . 
								$aro['Aro']['model'] . '/' . 
								$aro['Aro']['foreign_key'] . '/' . 
								$path[$i]) == true)
					{
						echo 'True1';
						//echo $path[$i];
					}
					//else if($this->requestAction('Aros/getAccessPermission/' . $path[$i] . '/' . $aroAlias) == false)
					else if($this->requestAction('Aros/getPerm/' . $aro['Aro']['model'] . '/' . $aro['Aro']['foreign_key'] . '/' . $path[$i]) == false)
						echo 'False1';
					/*else{
						
						$copyPath = '';
						//copy($path[$i], $copyPath);
						$substr = substr($path[$i], 0, strrpos($path[$i], '-'));
						
						
						$flag = false;
						do{
							//$substr = str_replace("-", "/", $substr);
							//echo $substr;
							//$allowed = $this->requestAction('Aros/getAccessPermission/' . $substr . '/' . $aroAlias);
							$allowed = $this->requestAction('Aros/getPerm/' . $aro['Aro']['model'] 
													. '/' . $aro['Aro']['foreign_key'] 
													. '/' . $substr);
							if($allowed != null){
								
								if($allowed == true){
									echo 'True';
								}
								else{
									echo 'False';
								}
								$flag = true;
								break;	
							}
							if(strrpos($substr, '-') != null){
								$substr = substr($substr, 0, strrpos($substr, '-'));
							}
							
						}while(strrpos($substr, '-') != null);
						if($flag == false){
							//$allowed = $this->requestAction('Aros/getAccessPermission/' . $substr . '/' . $aroAlias);
							$allowed = $this->requestAction('Aros/getPerm/' . $aro['Aro']['model'] 
															. '/' . $aro['Aro']['foreign_key'] 
															. '/' . $substr);
							if($allowed != null){
								if($allowed == true){
									echo 'True';
								}
								else if($allowed == false){
									echo 'False';
								}
								$flag = true;
								break;	
							}
						}
					}*/
//					$substr = substr($path[$i], 0, strpos($path[$i], '-'));
//					echo $substr;	
				?>
								
				</td>
			</tr>
		<?php 
			$i++;
		} 
		?>
	</table>
	
</body>